public class DEV521_S75Extension {




  private final ApexPages.StandardController c;
  public DEV521_S75Extension (ApexPages.StandardController c) {this.c = c;}
  
  // ページ生成時に呼び出されるコード
  public PageReference autoRun() {
    try {
      List<Position__c> l = 
       [select id, Priority__c from Position__c where Id!=:c.getId()];
      for (Position__c i : l) i.Priority__c = 'Low';
      update l;
      Position__c p = (Position__c)c.getRecord();
      p.Priority__c = 'Critical';
      update p;
    } catch (Exception e) {
      ApexPages.addmessages(e); // 例外をメッセージに追加
      return null;
    }
    return c.view().setRedirect(false);
  }
/* */
}